package com.newMedical.doclist.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.newMedical.common.annotation.Log;
import com.newMedical.common.core.controller.BaseController;
import com.newMedical.common.core.domain.AjaxResult;
import com.newMedical.common.enums.BusinessType;
import com.newMedical.doclist.domain.DocUser;
import com.newMedical.doclist.service.IDocUserService;
import com.newMedical.common.utils.poi.ExcelUtil;
import com.newMedical.common.core.page.TableDataInfo;

/**
 * 医生表Controller
 * 
 * @author ruoyi
 * @date 2021-12-01
 */
@RestController
@RequestMapping("/doclist/docList")
public class DocUserController extends BaseController
{
    @Autowired
    private IDocUserService docUserService;

    /**
     * 查询医生表列表
     */
    @PreAuthorize("@ss.hasPermi('doclist:docList:list')")
    @GetMapping("/list")
    public TableDataInfo list(DocUser docUser)
    {
        startPage();
        List<DocUser> list = docUserService.selectDocUserList(docUser);
        return getDataTable(list);
    }

    /**
     * 导出医生表列表
     */
    @PreAuthorize("@ss.hasPermi('doclist:docList:export')")
    @Log(title = "医生表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DocUser docUser)
    {
        List<DocUser> list = docUserService.selectDocUserList(docUser);
        ExcelUtil<DocUser> util = new ExcelUtil<DocUser>(DocUser.class);
        util.exportExcel(response, list, "医生表数据");
    }

    /**
     * 获取医生表详细信息
     */
    @PreAuthorize("@ss.hasPermi('doclist:docList:query')")
    @GetMapping(value = "/{docId}")
    public AjaxResult getInfo(@PathVariable("docId") Long docId)
    {
        return AjaxResult.success(docUserService.selectDocUserByDocId(docId));
    }

    /**
     * 新增医生表
     */
    @PreAuthorize("@ss.hasPermi('doclist:docList:add')")
    @Log(title = "医生表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocUser docUser)
    {
        return toAjax(docUserService.insertDocUser(docUser));
    }

    /**
     * 修改医生表
     */
    @PreAuthorize("@ss.hasPermi('doclist:docList:edit')")
    @Log(title = "医生表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocUser docUser)
    {
        return toAjax(docUserService.updateDocUser(docUser));
    }

    /**
     * 删除医生表
     */
    @PreAuthorize("@ss.hasPermi('doclist:docList:remove')")
    @Log(title = "医生表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{docIds}")
    public AjaxResult remove(@PathVariable Long[] docIds)
    {
        return toAjax(docUserService.deleteDocUserByDocIds(docIds));
    }
}
